package com.snack.shop.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 创建订单参数
 */
@Data
@Schema(description = "创建订单参数")
public class CreateOrderParam {

    @Schema(description = "订单类型：1-零食购买，2-取快递，3-取外卖，4-代买", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "订单类型不能为空")
    private Integer orderType;

    @Schema(description = "收货地址ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "收货地址不能为空")
    private Long addressId;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "商品列表（零食购买订单必填）", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "商品列表不能为空")
    private List<OrderItemParam> items;

    @Data
    @Schema(description = "订单商品项")
    public static class OrderItemParam {
        @Schema(description = "商品ID", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "商品ID不能为空")
        private Long productId;

        @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "购买数量不能为空")
        private Integer quantity;
    }
}

